package com.eedi.framework.social.dal.mapper;

import com.eedi.framework.common.enums.UserTypeEnum;
import com.eedi.framework.common.pojo.PageResult;
import com.eedi.framework.mybatis.core.mapper.BaseMapperX;
import com.eedi.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.eedi.framework.social.org.vo.client.OrgSocialClientPageReq;
import com.eedi.framework.social.dal.dataobject.OrgSocialClientDO;
import com.eedi.framework.social.enmus.OrgSocialTypeEnum;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface OrgSocialClientMapper extends BaseMapperX<OrgSocialClientDO> {

    default OrgSocialClientDO selectBySocialTypeAndUserType(OrgSocialTypeEnum socialType, UserTypeEnum userType) {
        return selectOne(OrgSocialClientDO::getOrgSocialClientType, socialType,
                OrgSocialClientDO::getOrgSocialUserType, userType);
    }

    default PageResult<OrgSocialClientDO> selectPage(OrgSocialClientPageReq reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OrgSocialClientDO>()
                .likeIfPresent(OrgSocialClientDO::getOrgSocialClientName, reqVO.getOrgSocialClientName())
                .eqIfPresent(OrgSocialClientDO::getOrgSocialClientType, reqVO.getOrgSocialClientType())
                .eqIfPresent(OrgSocialClientDO::getOrgSocialUserType, reqVO.getOrgSocialUserType())
                .likeIfPresent(OrgSocialClientDO::getClientId, reqVO.getClientId())
                .eqIfPresent(OrgSocialClientDO::getOrgSocialClientStatus, reqVO.getOrgSocialClientStatus())
                .orderByDesc(OrgSocialClientDO::getId));
    }

}
